package com.noble.library.basic;

import com.noble.library.basic.convert.TypeConvertUtil;
import com.noble.library.basic.sp.PSP;

/**
 * 全局常量类
 * Created by Su on 2017/12/1.
 */
public class Constant {

    // 设置页
    public static final String SET_BGM = "setting_bgm";
    public static final String SET_VOICE = "setting_voice";

    // App是否属于前台显示
    public static final String APP_IS_FOREGROUND = "noble_is_foreground";

    // 是否是双击退出
    public static final String APP_EXIT_DOUBLE = "app_exit_double";

    // 是否是首次安装
    public static final String APP_FIRST_INSTALL = "app_first_install";

    // ============ 各换皮包常量 ==================================
    // 包渠道号
    public static final String APP_CHANNEL = "app_channel";
    private static int channel = 0;

    private static void reGetChannel() {
        if (channel == 0) {
            channel = TypeConvertUtil.toInt(PSP.getInstance().getString(APP_CHANNEL, "0"), 0);
        }
    }

    /**
     * 1: 原包  2： 微信支付包   3： 换皮包
     */
    public static int getAppId() {
        reGetChannel();
        int APP_ID;
        if (channel <= 500) {   // 初始原包
            APP_ID = 1;
        } else if (channel <= 1000) {  // 微信支付更换包
            APP_ID = 2;
        } else {                     // 换皮包
            APP_ID = 3;
        }
        return APP_ID;
    }

    public static String getPspName() {
        reGetChannel();
        String pspName;
        if (channel <= 500) {   // 初始原包
            pspName = "dm_master_";
        } else if (channel <= 1000) {  // 微信支付更换包
            pspName = "dm_wx_";
        } else {                     // 换皮包
            pspName = "dm_skin_";
        }
        return pspName;
    }

}
